home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Jun 90 / MacApp.Tech$ 6⁄1⁄90 / 1368-EraseRect problems-May90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  3.8 KB  |  107 lines  |  [TEXT/GEOL]

  1. Item    6889313                         29-May-90        18:38PDT
  2.  
  3. From:   D1974                           NorthWest Rsch Assoc, D Lucas,PRT
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. cc:     MACAPP.TEST                     MacApp SQA Team
  8.         SCHMUCKER1                      Schmucker, Kurt
  9.         D1974                           NorthWest Rsch Assoc, D Lucas,PRT
  10.  
  11. Sub:    EraseRect problems
  12.  
  13. I would appreciate ideas on a couple of problems I have run into while
  14. converting my app from ß9 to 2.0.  The first problem involves the Draw and
  15. DrawContents methods of TWindow.  In ß9, TWindow.Draw did only one thing:  it
  16. called EraseRect to clear its area.  This caused a lot of unneccessary (and
  17. visually annoying) screen clearing and drawing at update time, and in my ß9
  18. version I had overriden this method to do nothing, which worked fine.  In 2.0,
  19. TWindow.Draw does nothing, and the EraseRect has been moved to
  20. TWindow.DrawContents as follows (code conditioned on
  21. qExperimentalAndUnsupported has been deleted):
  22.  
  23. PROCEDURE TWindow.DrawContents; OVERRIDE;
  24. VAR
  25.   visRect: Rect;
  26.  
  27.   PROCEDURE DoDrawContents;
  28.  
  29.   VAR
  30.     visRect:   Rect;
  31.  
  32.   BEGIN
  33.     IF Focus THEN
  34.      BEGIN
  35.      GetVisibleRect(visRect);
  36.      EraseRect(visRect);
  37.      INHERITED DrawContents;
  38.      IF fIsResizable THEN
  39.      DrawResizeIcon;
  40.      END;
  41.   END;
  42.  
  43.    BEGIN
  44.    DoDrawContents;
  45.    END;
  46.  
  47. The inheritted DrawContents is TView.DrawContents, which tells all subviews to
  48. Draw themselves and send their subviews the DrawContents message.  Here's my
  49. problem:  If I override TWindow.DrawContents to skip the EraseRect, there is no
  50. way to call TView.DrawContents.  I would like to call INHERITED INHERITED
  51. DrawContents, but of course the language doesn't support this.  I have a kludgy
  52. solution, which is to define a new method, TMyWindow.MyInheritedDrawContents,
  53. which is just a copy of TView.DrawContents.  Then my override of
  54. TWindow.DrawContents is
  55.  
  56. PROCEDURE TMyWindow.DrawContents; OVERRIDE;
  57. VAR
  58.   visRect: Rect;
  59.  
  60. PROCEDURE DoDrawContents;
  61.  
  62.   BEGIN
  63.   IF Focus THEN
  64.      BEGIN
  65.      SELF.MyInheritedDrawContents;
  66.      IF fIsResizable THEN DrawResizeIcon;
  67.      END;
  68.   END;
  69.  
  70.    BEGIN
  71.    DoDrawContents;
  72.    END;
  73.  
  74. This works, but surely there is a better way.  Perhaps this is a bug.  Why
  75. wasn't the EraseRect left in TWindow.Draw, where it could be avoided with a
  76. simple override?  Or am I missing something obvious?  Incidentally, the release
  77. notes for 2.0 makes no mention of these changes from ß9.
  78.  
  79. My second problem also has to do with EraseRect, but, ironically, in this case
  80. 2.0 doesn't clear the screen where it should, in contrast to the case above.
  81. It all revolves around the Draw, ImageText, and SetText methods of TStaticText.
  82. I have a TStaticText installed on top of another view that clears the screen to
  83. a dark gray in its Draw method.  I want the TStaticText to display its text on
  84. a white background surrounded by gray.  This worked fine in ß9, apparently
  85. because Draw called ImageText which called the toolbox procedure TextBox, which
  86. cleared the backgound to the current background color, which for me was white.
  87. Now I find that 2.0 has replaced the call to TextBox by a call to MATextBox,
  88. which seems to display its text without clearing the background.  So when the
  89. window first appears I get unreadable black text on a dark gray background.  It
  90. may happen that the text will change, in which case I call SetText, which does
  91. an EraseRect before calling Draw!  Then the updated text becomes the desired
  92. black on white.
  93.  
  94. Do I have to override TStaticText to get the desired behavior?  Why was this
  95. changed from ß9?  Again, none of this is mentioned in the release notes where
  96. the changes since ß9 are listed.
  97.  
  98. Thanks for any ideas or comments you may have.  Please link them to me at
  99. D1974, as I am not tracking MACAPP.TECH$.
  100.  
  101. Dave Lucas,
  102. Visualogic, Inc.
  103.  
  104.  
  105.  
  106.  
  107.